package org.compression.config;

import org.apache.catalina.filters.RemoteIpFilter;
import org.compression.filter.AuthFilter;
import org.compression.filter.UserCostFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

@Configuration
public class ConfigurationFilter {



	@Bean
	public RemoteIpFilter remoteIpFilter() {
		return new RemoteIpFilter();
	}
	
	
	@Bean
	public UserCostFilter getIpFilter() {
		return new UserCostFilter();
	}
/*	
	@Bean
	public AuthFilter getAuthFilter() {
		return new AuthFilter();
	}*/


	@Bean
	public FilterRegistrationBean testFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(getIpFilter());//添加过滤器
	
		registration.addInitParameter("exclusions","/auth/*");//不过顾虑
		registration.addUrlPatterns("/*");//设置过滤路径，/*所有路径
		//registration.addUrlPatterns("/*");
		registration.addInitParameter("name", "alue");//添加默认参数
		registration.setName("MyFilter");//设置优先级
		registration.setOrder(1);//设置优先级
		return registration;
	}



	 
	/*@Bean
	public FilterRegistrationBean AuthFilterRegistration() {
		InterceptorRegistry registration = new InterceptorRegistry();
		registration.setFilter(getAuthFilter());//添加过滤器4
		registration.excludePathPatterns();
		registration.addInitParameter("exclusions","/auth/*");//不过过滤
		registration.addUrlPatterns("/*");//设置过滤路径，/*所有路径
		//registration.addUrlPatterns("/*");
		registration.addInitParameter("name", "alue");//添加默认参数
		registration.setName("MyFilter2");//设置优先级
		registration.setOrder(10);//设置优先级
		return registration;
	}*/




}
